package com.ham.mud.characters;

/**
 * Created by hlucas on Jun 27, 2011 at 1:29:22 PM
 */
public class Vitals {
    private int health;
    private int maxHealth;

    private int mana;
    private int maxMana;

    private int move;
    private int maxMove;

    public Vitals(int health, int maxHealth, int mana, int maxMana, int move, int maxMove) {
        this.health = health;
        this.maxHealth = maxHealth;
        this.mana = mana;
        this.maxMana = maxMana;
        this.move = move;
        this.maxMove = maxMove;
    }

    public int getHealth() {
        return health;
    }

    public void setHealth(int health) {
        this.health = health;
    }

    public void decrementHealth(int by) {
        health -= by;
    }

    public void incrementHealth(int by) {
        health += by;
        if(health > maxHealth) {
            health = maxHealth;
        }
    }

    public void decrementMove(int by) {
        move -= by;
    }

    public void incrementMove(int by) {
        move += by;
        if(move > maxMove) {
            move = maxMove;
        }
    }

    public void decrementMana(int by) {
        mana -= by;
    }

    public void incrementMana(int by) {
        mana += by;
        if(mana > maxMana) {
            mana = maxMana;
        }
    }

    public int getMana() {
        return mana;
    }

    public void setMana(int mana) {
        this.mana = mana;
    }

    public int getMove() {
        return move;
    }

    public void setMove(int move) {
        this.move = move;
    }

    public int getMaxHealth() {
        return maxHealth;
    }

    public void setMaxHealth(int maxHealth) {
        this.maxHealth = maxHealth;
    }

    public int getMaxMana() {
        return maxMana;
    }

    public void setMaxMana(int maxMana) {
        this.maxMana = maxMana;
    }

    public int getMaxMove() {
        return maxMove;
    }

    public void setMaxMove(int maxMove) {
        this.maxMove = maxMove;
    }

    public boolean regenHealth(double modifier) {
        boolean didRegen = false;
        if(health < maxHealth) {
            double regen = ((double)maxHealth) / 5.0;
            if(regen < 1) {
                regen = 1;
            }
            health += regen*modifier;
            didRegen = true;
        }

        if(health > maxHealth) {
            health = maxHealth;
        }
        return didRegen;
    }

    public boolean regenMana(double modifier) {
        boolean didRegen = false;
        if(mana < maxMana) {
            double regen = ((double)maxMana) / 5.0;
            if(regen < 1) {
                regen = 1;
            }
            mana += regen*modifier;
            didRegen = true;
        }

        if(mana > maxMana) {
            mana = maxMana;
        }
        return didRegen;
    }

    public boolean regenMove(double modifier) {
        boolean didRegen = false;
        if(move < maxMove) {
            double regen = ((double)maxMove) / 5.0;
            if(regen < 1) {
                regen = 1;
            }
            move += regen*modifier;
            didRegen = true;
        }

        if(move > maxMove) {
            move = maxMove;
        }
        return didRegen;
    }

    @Override
    public String toString() {
        return health + "/" + maxHealth + "hp " + move + "/" + maxMove + "mv " + mana + "/" + maxMana + "m";
    }
}
